Skip to content

Add model validation on model_copy to ConfigBaseModel#118

Open
cfs-data wants to merge 3 commits intomainfrom
add-validation-on-model-copy
Open

Add model validation on model_copy to ConfigBaseModel#118
cfs-data wants to merge 3 commits intomainfrom
add-validation-on-model-copy

Conversation

@cfs-data
Copy link
Collaborator

@cfs-data cfs-data commented Feb 4, 2026

Issue: in many places we use model_copy(update=...) which does not trigger validation routines.

Solution: Override the method in base class so that pydantic models are validated even when using model_copy.

This triggered two exceptions in unit tests:

  • An exception for an incorrect extra field assignment of _center in a Mark instance (which has been renamed to center_). This has been fixed by simply renaming the keyword
  • An exception from numpy for trying to coerce a tuple to numpy.floating. This has been fixed by making the target datatype explicit: numpy.float64

@cfs-data cfs-data changed the title Add model validation on model_copy [Draft] Add model validation on model_copy Feb 4, 2026
@cfs-data cfs-data changed the title [Draft] Add model validation on model_copy Add model validation on model_copy Feb 4, 2026
@cfs-data cfs-data changed the title Add model validation on model_copy Add model validation on model_copy to BaseModel Feb 4, 2026
@cfs-data cfs-data changed the title Add model validation on model_copy to BaseModel Add model validation on model_copy to ConfigBaseModel Feb 4, 2026
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Diff Coverage

Diff: origin/main..HEAD, staged and unstaged changes

  • packages/scratch-core/src/container_models/base.py (100%)
  • packages/scratch-core/src/conversion/preprocess_impression/utils.py (100%)

Summary

  • Total: 15 lines
  • Missing: 0 lines
  • Coverage: 100%

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Code Coverage

Package Line Rate Branch Rate Health
. 96% 88%
comparators 100% 100%
computations 100% 100%
container_models 99% 100%
conversion 97% 86%
conversion.export 100% 100%
conversion.filter 92% 83%
conversion.leveling 100% 100%
conversion.leveling.solver 100% 75%
conversion.plots 98% 85%
conversion.preprocess_impression 99% 91%
conversion.preprocess_striation 89% 58%
extractors 98% 75%
mutations 100% 100%
parsers 98% 80%
parsers.patches 89% 60%
preprocessors 95% 75%
processors 100% 100%
renders 98% 50%
utils 91% 75%
Summary 96% (2004 / 2077) 82% (207 / 254)

Minimum allowed line rate is 50%

Copy link
Collaborator

@Raytesnel Raytesnel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think model_copy will not be used after all the upcoming changes of the ImageMutation. but more validations are always welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants